package com.itheima.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/*


Executors  线程池工具类

ExecutorService  线程池 接口

ThreadPoolExecutor 线程池 实现类
 */
public class Demo01 {


    public static void main(String[] args) {
        //创建线程池
        ExecutorService pool = Executors.newCachedThreadPool();
        //给任务
        pool.submit(()->{
            for (int i = 0; i < 100; i++) {
                String name = Thread.currentThread().getName();
                System.out.println(name+"执行到了"+i);
            }
        });
        pool.submit(()->{
            for (int i = 0; i < 100; i++) {
                String name = Thread.currentThread().getName();
                System.out.println(name+"执行到了"+i);
            }
        });
        //销毁池子
        pool.shutdown();
    }
}
